
import React, { PropTypes } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';

import { beginSetYear, beginSetMonth, beginSetDay } from '../../actions/actionAsyncDemo'
import Year from '../../components/Year';
import Month from '../../components/Month';
import Day from '../../components/Day';

class AsnycDemo extends React.Component {
    constructor(props) {
        super(props);
    }

    render() {
        const props = this.props;
        console.log(this.props)
        return (<div>
            <div>
                {this.props.year}年{this.props.month || '-'}月{this.props.day || '-'}日
            </div>
            <div>
                <Year begin={props.begin} end={props.end} year={this.props.year} onChange={
                    (year) => {
                        debugger;
                        this.props.dispatch(beginSetYear(year))
                    }
                } />年
                <Month year={this.props.year} month={this.props.month} onChange={(month) => { this.props.dispatch(beginSetMonth(month)) }} />月
                <Day year={this.props.year} month={this.props.month} day={this.props.day} onChange={(day) => { this.props.dispatch(beginSetDay(day)) }} />日
            </div>
        </div>);
    }
}

const mapStateToProps = state => state.asyncState;

export default connect(mapStateToProps)(AsnycDemo);
